
	.386
if ?FLAT
	.MODEL FLAT, stdcall
else
	.MODEL SMALL, stdcall
endif
	option casemap:none
	option proc:private

	include winbase.inc
	include macros.inc

	.CODE

;--- if FILE_TYPE_UNKNOWN is returned, last error has to be set!

GetFileType proc public uses ebx handle:dword

	mov ebx,handle
	cmp ebx,10000h
	ja  unknown
	mov ax,4400h
	int 21h
	jc invalid
	test dl,80h				;device?
	mov eax,FILE_TYPE_CHAR
	jnz exit
if 0	;v3.7: type FILE_TYPE_REMOTE is "unused"
	test dh,80h				;remote flag set?
	mov eax,FILE_TYPE_REMOTE
	jnz exit
endif
	mov eax,FILE_TYPE_DISK
	jmp exit
unknown:
	invoke SetLastError, NO_ERROR
	mov eax,FILE_TYPE_UNKNOWN
	jmp exit
invalid:
	movzx eax, ax
	invoke SetLastError, eax
	mov eax,FILE_TYPE_UNKNOWN
exit:
	@strace  <"GetFileType(", handle, ")=", eax>
	ret
GetFileType endp

end
